<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 5.4.2">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha256-HtsXJanqjKTc8vVQjO4YMhiqFoXkfBsjBWcX91T1jr8=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"xiaoqingming18.github.io","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.15.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>

    <meta name="description" content="进位计数制 r进制计数法 任意进制→十进制 二进制→八进制和十六进制 各种进制常见的书写方式 十进制→任意进制  真值和机器数 本节知识回顾与总结 BCD码BCD码是一种用二进制数码来表示十进制数的编码方式。它将一个十进制数的每个十进制位数码化为4位二进制数来表示，每个4位二进制数的取值范围是0000-1001，即十进制的0-9。因此，一个BCD码可以表示一个十进制数的每个十进制位。例如，数字12">
<meta property="og:type" content="article">
<meta property="og:title" content="计算机组成原理：运算方法和运算器">
<meta property="og:url" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/index.html">
<meta property="og:site_name" content="鸣蜩十七">
<meta property="og:description" content="进位计数制 r进制计数法 任意进制→十进制 二进制→八进制和十六进制 各种进制常见的书写方式 十进制→任意进制  真值和机器数 本节知识回顾与总结 BCD码BCD码是一种用二进制数码来表示十进制数的编码方式。它将一个十进制数的每个十进制位数码化为4位二进制数来表示，每个4位二进制数的取值范围是0000-1001，即十进制的0-9。因此，一个BCD码可以表示一个十进制数的每个十进制位。例如，数字12">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/进位计数制.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/r进制计数法.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/任意进制转化十进制.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/二进制转化为八进制和十六进制.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/各种进制常见的书写方式.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/十进制转化为任意进制1.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/十进制转化为任意进制2.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/真值和机器数.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/知识回顾1.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/8421码.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/8位机器字长无符号整数表示.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/无符号整数表示细节.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/无符号整数加法运算.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/无符号整数减法.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/减数变换.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/减法变加法.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/原码表示.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/原码缺点.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/各种码的特性总结.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/有符号整数总结.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/定点小数的原码表示.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/各种码互换.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/定点小数的加减运算.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/ALU.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/基本逻辑运算.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/符合逻辑.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/一位全加器.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/串行加法器.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/并行加法器.png">
<meta property="og:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/ALU回顾.png">
<meta property="article:published_time" content="2023-05-08T12:11:44.000Z">
<meta property="article:modified_time" content="2023-06-14T09:23:58.429Z">
<meta property="article:author" content="鸣蜩十七">
<meta property="article:tag" content="-计算机组成原理 -笔记">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/进位计数制.png">


<link rel="canonical" href="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/","path":"2023/05/08/计算机组成原理：运算方法和运算器/","title":"计算机组成原理：运算方法和运算器"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>计算机组成原理：运算方法和运算器 | 鸣蜩十七</title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>

<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">鸣蜩十七</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">鸣蜩十七是和女朋友谈恋爱的日子</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-schedule"><a href="/schedule/" rel="section"><i class="fa fa-calendar fa-fw"></i>日程表</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a></li><li class="menu-item menu-item-commonweal"><a href="/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a></li>
  </ul>
</nav>




</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%BF%9B%E4%BD%8D%E8%AE%A1%E6%95%B0%E5%88%B6"><span class="nav-text">进位计数制</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#r%E8%BF%9B%E5%88%B6%E8%AE%A1%E6%95%B0%E6%B3%95"><span class="nav-text">r进制计数法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BB%BB%E6%84%8F%E8%BF%9B%E5%88%B6%E2%86%92%E5%8D%81%E8%BF%9B%E5%88%B6"><span class="nav-text">任意进制→十进制</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%8C%E8%BF%9B%E5%88%B6%E2%86%92%E5%85%AB%E8%BF%9B%E5%88%B6%E5%92%8C%E5%8D%81%E5%85%AD%E8%BF%9B%E5%88%B6"><span class="nav-text">二进制→八进制和十六进制</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%90%84%E7%A7%8D%E8%BF%9B%E5%88%B6%E5%B8%B8%E8%A7%81%E7%9A%84%E4%B9%A6%E5%86%99%E6%96%B9%E5%BC%8F"><span class="nav-text">各种进制常见的书写方式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8D%81%E8%BF%9B%E5%88%B6%E2%86%92%E4%BB%BB%E6%84%8F%E8%BF%9B%E5%88%B6"><span class="nav-text">十进制→任意进制</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%9C%9F%E5%80%BC%E5%92%8C%E6%9C%BA%E5%99%A8%E6%95%B0"><span class="nav-text">真值和机器数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%AC%E8%8A%82%E7%9F%A5%E8%AF%86%E5%9B%9E%E9%A1%BE%E4%B8%8E%E6%80%BB%E7%BB%93"><span class="nav-text">本节知识回顾与总结</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#BCD%E7%A0%81"><span class="nav-text">BCD码</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#8421%E7%A0%81"><span class="nav-text">8421码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BD%993%E7%A0%81"><span class="nav-text">余3码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2421%E7%A0%81"><span class="nav-text">2421码</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E4%B8%8E%E6%96%87%E5%AD%97%E7%9A%84%E8%A1%A8%E7%A4%BA%E6%96%B9%E6%B3%95"><span class="nav-text">数据与文字的表示方法</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%97%A0%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%E7%9A%84%E8%A1%A8%E7%A4%BA%E5%92%8C%E8%BF%90%E7%AE%97"><span class="nav-text">无符号整数的表示和运算</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%97%A0%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%E5%9C%A8%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%86%85%E9%83%A8%E7%9A%84%E8%A1%A8%E7%A4%BA"><span class="nav-text">无符号整数在计算机内部的表示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%97%A0%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%E7%9A%84%E5%8A%A0%E6%B3%95%E8%BF%90%E7%AE%97"><span class="nav-text">无符号整数的加法运算</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%97%A0%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%E7%9A%84%E5%87%8F%E6%B3%95%E8%BF%90%E7%AE%97"><span class="nav-text">无符号整数的减法运算</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%A6%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%E7%9A%84%E8%BF%90%E7%AE%97%E5%92%8C%E8%A1%A8%E7%A4%BA"><span class="nav-text">带符号整数的运算和表示</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8E%9F%E7%A0%81%E8%A1%A8%E7%A4%BA"><span class="nav-text">原码表示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8E%9F%E7%A0%81%E8%A1%A8%E7%A4%BA%E6%B3%95%E7%BC%BA%E7%82%B9"><span class="nav-text">原码表示法缺点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8E%9F%E7%A0%81%E8%BD%AC%E5%8C%96%E4%B8%BA%E8%A1%A5%E7%A0%81"><span class="nav-text">原码转化为补码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A1%A5%E7%A0%81%E8%BD%AC%E5%8C%96%E4%B8%BA%E5%8E%9F%E7%A0%81"><span class="nav-text">补码转化为原码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A1%A5%E7%A0%81%E5%8A%A0%E6%B3%95%E8%BF%90%E7%AE%97"><span class="nav-text">补码加法运算</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A1%A5%E7%A0%81%E5%87%8F%E6%B3%95%E8%BF%90%E7%AE%97"><span class="nav-text">补码减法运算</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%90%84%E7%A7%8D%E7%A0%81%E7%9A%84%E7%89%B9%E6%80%A7%E6%80%BB%E7%BB%93"><span class="nav-text">各种码的特性总结</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%AC%E8%8A%82%E6%80%BB%E7%BB%93"><span class="nav-text">本节总结</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A7%BB%E7%A0%81"><span class="nav-text">移码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9A%E7%82%B9%E5%B0%8F%E6%95%B0%E7%9A%84%E8%A1%A8%E7%A4%BA%E5%92%8C%E8%BF%90%E7%AE%97"><span class="nav-text">定点小数的表示和运算</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%9A%E7%82%B9%E5%B0%8F%E6%95%B0%E7%9A%84%E5%8E%9F%E7%A0%81%E8%A1%A8%E7%A4%BA"><span class="nav-text">定点小数的原码表示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%9A%E7%82%B9%E5%B0%8F%E6%95%B0%E7%9A%84%E5%8E%9F-%E5%8F%8D-%E8%A1%A5%E7%A0%81%E7%9A%84%E8%BD%AC%E6%8D%A2"><span class="nav-text">定点小数的原&#x2F;反&#x2F;补码的转换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%9A%E7%82%B9%E5%B0%8F%E6%95%B0%E7%9A%84%E5%8A%A0%E5%87%8F%E8%BF%90%E7%AE%97"><span class="nav-text">定点小数的加减运算</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%AE%97%E6%9C%AF%E9%80%BB%E8%BE%91%E5%8D%95%E5%85%83ALU%EF%BC%88%E7%94%B5%E8%B7%AF%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86-amp-%E5%8A%A0%E6%B3%95%E5%99%A8%E8%AE%BE%E8%AE%A1%EF%BC%89"><span class="nav-text">算术逻辑单元ALU（电路基本原理&amp;加法器设计）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%80%E5%9F%BA%E6%9C%AC%E7%9A%84%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97"><span class="nav-text">最基本的逻辑运算</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%A4%8D%E5%90%88%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97"><span class="nav-text">复合逻辑运算</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%80%E4%BD%8D%E5%85%A8%E5%8A%A0%E5%99%A8"><span class="nav-text">一位全加器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%B2%E8%A1%8C%E5%8A%A0%E6%B3%95%E5%99%A8"><span class="nav-text">串行加法器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B9%B6%E8%A1%8C%E5%8A%A0%E6%B3%95%E5%99%A8"><span class="nav-text">并行加法器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%AC%E8%8A%82%E5%9B%9E%E9%A1%BE"><span class="nav-text">本节回顾</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">鸣蜩十七</p>
  <div class="site-description" itemprop="description">记录我的学习、生活和恋爱日常</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">43</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://xiaoqingming18.github.io/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="鸣蜩十七">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="鸣蜩十七">
      <meta itemprop="description" content="记录我的学习、生活和恋爱日常">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="计算机组成原理：运算方法和运算器 | 鸣蜩十七">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          计算机组成原理：运算方法和运算器
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-05-08 20:11:44" itemprop="dateCreated datePublished" datetime="2023-05-08T20:11:44+08:00">2023-05-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-06-14 17:23:58" itemprop="dateModified" datetime="2023-06-14T17:23:58+08:00">2023-06-14</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86/" itemprop="url" rel="index"><span itemprop="name">-计算机组成原理</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="进位计数制"><a href="#进位计数制" class="headerlink" title="进位计数制"></a>进位计数制</h1><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/进位计数制.png" alt="进位计数制"></p>
<h2 id="r进制计数法"><a href="#r进制计数法" class="headerlink" title="r进制计数法"></a>r进制计数法</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/r进制计数法.png" alt="r进制计数法"></p>
<h2 id="任意进制→十进制"><a href="#任意进制→十进制" class="headerlink" title="任意进制→十进制"></a>任意进制→十进制</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/任意进制转化十进制.png" alt="任意进制转化十进制"></p>
<h2 id="二进制→八进制和十六进制"><a href="#二进制→八进制和十六进制" class="headerlink" title="二进制→八进制和十六进制"></a>二进制→八进制和十六进制</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/二进制转化为八进制和十六进制.png" alt="二进制转化为八进制和十六进制"></p>
<h2 id="各种进制常见的书写方式"><a href="#各种进制常见的书写方式" class="headerlink" title="各种进制常见的书写方式"></a>各种进制常见的书写方式</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/各种进制常见的书写方式.png" alt="各种进制常见的书写方式"></p>
<h2 id="十进制→任意进制"><a href="#十进制→任意进制" class="headerlink" title="十进制→任意进制"></a>十进制→任意进制</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/十进制转化为任意进制1.png" alt="十进制转化为任意进制1"></p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/十进制转化为任意进制2.png" alt="十进制转化为任意进制2"></p>
<h2 id="真值和机器数"><a href="#真值和机器数" class="headerlink" title="真值和机器数"></a>真值和机器数</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/真值和机器数.png" alt="真值和机器数"></p>
<h2 id="本节知识回顾与总结"><a href="#本节知识回顾与总结" class="headerlink" title="本节知识回顾与总结"></a>本节知识回顾与总结</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/知识回顾1.png" alt="本节知识回顾与总结"></p>
<h1 id="BCD码"><a href="#BCD码" class="headerlink" title="BCD码"></a>BCD码</h1><p>BCD码是一种用二进制数码来表示十进制数的编码方式。它将一个十进制数的每个十进制位数码化为4位二进制数来表示，每个4位二进制数的取值范围是0000-1001，即十进制的0-9。因此，一个BCD码可以表示一个十进制数的每个十进制位。例如，数字123的BCD码为0001 0010 0011。</p>
<p>与其他二进制编码方式相比，BCD码具有以下特点：</p>
<ol>
<li>BCD码可以直接表示十进制数，无需进行进制转换，方便了数字的计算和表示。</li>
<li>BCD码中的每个4位二进制数只能取0~9的十进制数码，不存在其他不合法的数值，因此不会出现进位或借位的情况，可以避免类似于浮点数计算中的舍入误差。</li>
<li>BCD码的编码密度比较低，需要更多的位数来表示同样的数字，因此占用的存储空间和传输带宽相对较大。</li>
</ol>
<p>BCD码又分为余3码和2421码，下面我们来看它们的具体区别。</p>
<h2 id="8421码"><a href="#8421码" class="headerlink" title="8421码"></a>8421码</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/8421码.png" alt="8421码"></p>
<p>要注意的是，用8421码时，若相加得到的结果超过表示范围0-9（0000-1001），则需要对结果进行加6（0110）修正，并在高位补齐0。</p>
<h2 id="余3码"><a href="#余3码" class="headerlink" title="余3码"></a>余3码</h2><p>余3码的编码规则是将一个10进制数的每个十进制位数值加上3，然后再将结果转换为4位二进制数。例如，数字123的余3码为0011 0100 0101，其中，1+3=4，2+3=5，3+3=6，它们分别被转换为4位二进制数0100、0101和0110。</p>
<p>余3码的主要特点是编码密度高、进位比较容易，但是它的反码加3的规则比较复杂，不方便进行计算和处理。</p>
<h2 id="2421码"><a href="#2421码" class="headerlink" title="2421码"></a>2421码</h2><p>2421码的编码规则是将一个10进制数的每个十进制位数值分别用4位二进制数表示，其中，千位数的编码方式为8421，百位、十位和个位的编码方式为将其对应的8421码反转后减去3的结果。例如，数字123的2421码为1000 0011 0010 0001，其中，百位数的8421码为0010，反转后为0101，减去3后得到0010，十位和个位数的8421码为0011和0001，反转后分别为1100和1110，减去3后分别得到1011和1101。</p>
<p>2421码的主要特点是编码规则简单、容易计算和处理，但是它的编码密度相对较低，需要更多的位数来表示同样的数字。</p>
<h1 id="数据与文字的表示方法"><a href="#数据与文字的表示方法" class="headerlink" title="数据与文字的表示方法"></a>数据与文字的表示方法</h1><h2 id="无符号整数的表示和运算"><a href="#无符号整数的表示和运算" class="headerlink" title="无符号整数的表示和运算"></a>无符号整数的表示和运算</h2><h3 id="无符号整数在计算机内部的表示"><a href="#无符号整数在计算机内部的表示" class="headerlink" title="无符号整数在计算机内部的表示"></a>无符号整数在计算机内部的表示</h3><p>我们以及机器字长为8位的机器为例，它的通用寄存器只能存8位，最多只能同时进行8位计算：</p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/8位机器字长无符号整数表示.png" alt="8位机器字长无符号整数表示"></p>
<p>下面来看无符号整数在计算机内部表示的细节：</p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/无符号整数表示细节.png" alt="无符号整数表示细节"></p>
<h3 id="无符号整数的加法运算"><a href="#无符号整数的加法运算" class="headerlink" title="无符号整数的加法运算"></a>无符号整数的加法运算</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/无符号整数加法运算.png" alt="无符号整数加法运算"></p>
<h3 id="无符号整数的减法运算"><a href="#无符号整数的减法运算" class="headerlink" title="无符号整数的减法运算"></a>无符号整数的减法运算</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/无符号整数减法.png" alt="无符号整数减法运算"></p>
<p>下面来看看减数B是怎么变的：</p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/减数变换.png" alt="减数变换"></p>
<p>然后减法变加法：</p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/减法变加法.png" alt="减法变加法"></p>
<h2 id="带符号整数的运算和表示"><a href="#带符号整数的运算和表示" class="headerlink" title="带符号整数的运算和表示"></a>带符号整数的运算和表示</h2><h3 id="原码表示"><a href="#原码表示" class="headerlink" title="原码表示"></a>原码表示</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/原码表示.png" alt="原码表示"></p>
<ol>
<li>注意以下内容：若机器字长$n+1$位，则带符号整数的表示范围为$-(2^n-1)≤x≤2^n-1$。</li>
<li>真值0有两种形式：$+0$和$-0$， $[+0]_原=0,0000000$， $[-0]_原=1,0000000$。</li>
</ol>
<h3 id="原码表示法缺点"><a href="#原码表示法缺点" class="headerlink" title="原码表示法缺点"></a>原码表示法缺点</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/原码缺点.png" alt="原码缺点"></p>
<p>为了克服这一缺点，引入补码以及补码运算。</p>
<h3 id="原码转化为补码"><a href="#原码转化为补码" class="headerlink" title="原码转化为补码"></a>原码转化为补码</h3><p>正数的原码就是补码，负数要先把原码先变为反码，即所有数值位取反，最后末尾加一就变成补码了。（切记不要动符号位哦！）</p>
<h3 id="补码转化为原码"><a href="#补码转化为原码" class="headerlink" title="补码转化为原码"></a>补码转化为原码</h3><p>正数的补码就是原码，负数的补码转化为原码，先从补码的右边开始数，数到第一个1时，这个1左边的所有<strong>数值位</strong>取反。</p>
<h3 id="补码加法运算"><a href="#补码加法运算" class="headerlink" title="补码加法运算"></a>补码加法运算</h3><p>补码加法：从最低位开始，按位相加（符号位而已参与运算），并往更高位进位。最后超出机器字长的高位进位舍弃。</p>
<h3 id="补码减法运算"><a href="#补码减法运算" class="headerlink" title="补码减法运算"></a>补码减法运算</h3><p>补码减法运算法则：</p>
<script type="math/tex; mode=display">[A]_补-[B]_补=[A]_补+[-B]_补</script><p>$[B]_补求[-B]_补$的方法：从右往左找到第一个1，这个1左边所有位取反（包括符号位），右边保持不变，就得到了$[B]_补$。</p>
<h3 id="各种码的特性总结"><a href="#各种码的特性总结" class="headerlink" title="各种码的特性总结"></a>各种码的特性总结</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/各种码的特性总结.png" alt="各种码的特性总结"></p>
<h3 id="本节总结"><a href="#本节总结" class="headerlink" title="本节总结"></a>本节总结</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/有符号整数总结.png" alt="有符号整数总结"></p>
<h2 id="移码"><a href="#移码" class="headerlink" title="移码"></a>移码</h2><p>在补码的基础上<strong>符号位取反</strong>就得到移码。</p>
<h2 id="定点小数的表示和运算"><a href="#定点小数的表示和运算" class="headerlink" title="定点小数的表示和运算"></a>定点小数的表示和运算</h2><h3 id="定点小数的原码表示"><a href="#定点小数的原码表示" class="headerlink" title="定点小数的原码表示"></a>定点小数的原码表示</h3><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/定点小数的原码表示.png" alt="定点小数原码表示"></p>
<h3 id="定点小数的原-反-补码的转换"><a href="#定点小数的原-反-补码的转换" class="headerlink" title="定点小数的原/反/补码的转换"></a>定点小数的原/反/补码的转换</h3><p>与上面说的定点整数（有符号整数）的转换规则一样：</p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/各种码互换.png" alt="各种码互换"></p>
<h3 id="定点小数的加减运算"><a href="#定点小数的加减运算" class="headerlink" title="定点小数的加减运算"></a>定点小数的加减运算</h3><p>这里也与定点整数的加减运算一样：</p>
<p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/定点小数的加减运算.png" alt="定点小数的加减运算"></p>
<h1 id="算术逻辑单元ALU（电路基本原理-amp-加法器设计）"><a href="#算术逻辑单元ALU（电路基本原理-amp-加法器设计）" class="headerlink" title="算术逻辑单元ALU（电路基本原理&amp;加法器设计）"></a>算术逻辑单元ALU（电路基本原理&amp;加法器设计）</h1><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/ALU.png" alt="ALU"></p>
<p>如上图，左边的$M$告诉CPU执行算术运算还是逻辑运算，$S_1$~$S_0$则告诉CPU执行哪一种算数运算或逻辑运算。</p>
<p>下面提供两个操作数，每个操作数是4bit的，这就是机器字长的真面目。</p>
<h2 id="最基本的逻辑运算"><a href="#最基本的逻辑运算" class="headerlink" title="最基本的逻辑运算"></a>最基本的逻辑运算</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/基本逻辑运算.png" alt="基本逻辑运算"></p>
<h2 id="复合逻辑运算"><a href="#复合逻辑运算" class="headerlink" title="复合逻辑运算"></a>复合逻辑运算</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/符合逻辑.png" alt="复合逻辑"></p>
<h2 id="一位全加器"><a href="#一位全加器" class="headerlink" title="一位全加器"></a>一位全加器</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/一位全加器.png" alt="一位全加器"></p>
<h2 id="串行加法器"><a href="#串行加法器" class="headerlink" title="串行加法器"></a>串行加法器</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/串行加法器.png" alt="串行加法器"></p>
<h2 id="并行加法器"><a href="#并行加法器" class="headerlink" title="并行加法器"></a>并行加法器</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/并行加法器.png" alt="并行加法器"></p>
<h2 id="本节回顾"><a href="#本节回顾" class="headerlink" title="本节回顾"></a>本节回顾</h2><p><img src="/2023/05/08/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%BF%90%E7%AE%97%E6%96%B9%E6%B3%95%E5%92%8C%E8%BF%90%E7%AE%97%E5%99%A8/ALU回顾.png" alt="ALU回顾"></p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86-%E7%AC%94%E8%AE%B0/" rel="tag"># -计算机组成原理 -笔记</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2023/05/07/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86%EF%BC%9A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F%E6%A6%82%E8%AE%BA/" rel="prev" title="计算机组成原理：计算机系统概论">
                  <i class="fa fa-chevron-left"></i> 计算机组成原理：计算机系统概论
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2023/05/08/Java%EF%BC%9A%E6%9E%9A%E4%B8%BE%E7%B1%BB%E5%92%8C%E5%8F%8D%E5%B0%84/" rel="next" title="Java：枚举类和反射">
                  Java：枚举类和反射 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">鸣蜩十七</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  




  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>



</body>
</html>
